package com.loren.demo07.simple.web.controller;

import com.loren.demo07.simple.handler.CustomSimpleMessageHandler;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@AllArgsConstructor
public class SimpleController {

    private final CustomSimpleMessageHandler customSimpleMessageHandler;

    @GetMapping("/to-user")
    public String sendToUser(@RequestParam("uuid") String uuid) throws IOException {
        this.customSimpleMessageHandler.sendTextMessage(uuid, "send to specified user");
        return "send to user";
    }

    @GetMapping("/to-group")
    public String sendToGroup() throws IOException {
        this.customSimpleMessageHandler.sendTextMessage("send to all user");
        return "send to group";
    }
}
